/**
 * 
 */
package br.srv.full.virtual.engine.numbers;

import java.util.UUID;

import javax.ejb.Local;
import javax.ejb.RemoteHome;
import javax.ejb.Stateless;
import javax.ejb.TransactionManagement;
import javax.ejb.TransactionManagementType;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

import br.srv.full.virtual.engine.number.NumberGenerator;
import br.srv.full.virtual.engine.number.NumberGeneratorLocal;
import br.srv.full.virtual.engine.number.NumberGeneratorRemote;

/**
 * @author Delfino
 * 
 */
@Stateless(name = "NumberGenerator", description="Gerador de numeros como UUID, GUID e Sequencer")
@Local(NumberGeneratorLocal.class)
public class NumberGeneratorEJB3 implements  NumberGeneratorLocal, NumberGeneratorRemote{

	private final Log log = LogFactory.getLog(getClass());

	public NumberGeneratorEJB3(){
		log.info("criado");
	}
	/*
	 * (non-Javadoc)
	 * 
	 * @see br.srv.full.virtual.engine.numbers.NumberGeneratorLocal#generateUserRegistrationId(br.srv.full.virtual.entities.resume.UserLogin)
	 */// 29d3d0a0-9866-3c29-9c46-fa26e12f4b3d
	public UUID generateUUID() {
		UUID l_uuid;
		// eu usava este pensando que era construido com base no tempo e nome
		// informado
		// mas a melhor forma é construir de forma randomica ou usando um indice
		// unico
		// l_uuid = UUID.nameUUIDFromBytes("br.srv.full.virtual".getBytes());
		l_uuid = UUID.randomUUID();
		log.info("UUID Gerado: " + l_uuid);
		log.debug("UUID Size: " + l_uuid.toString().length());

		return l_uuid;
	}

}
